import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class Schedule {
    private Film film;                // 放映的电影
    private ScreeningHall hall;       // 影厅对象
    private Date startTime;           // 开始时间
    private float finalPrice;         // 最终票价（基础价+影厅服务费）
    private Set<String> soldSeats;    // 已售座位集合

    public Schedule(Film film, ScreeningHall hall, Date startTime) {
        this.film = film;
        this.hall = hall;
        this.startTime = startTime;
        // 基础票价
        float basePrice = film.getBasicPrice();
        this.finalPrice = basePrice + hall.getServiceFee();
        this.soldSeats = new HashSet<>(); // 初始化已售座位集合
    }

    // 计算结束时间
    public Date getEndTime() {
        long durationMs = (long)film.getLength() * 60 * 1000;
        return new Date(startTime.getTime() + durationMs);
    }

    //getter
    public Film getFilm() { return film; }
    public ScreeningHall getHall() { return hall; }
    public float getFinalPrice() { return finalPrice; }
    public Date getStartTime() { return startTime; }

    //setter
    public void setFilm(Film film) { this.film = film; }
    public void setFinalPrice(float price) { this.finalPrice = price; }
    public void setHall(ScreeningHall hall) { this.hall = hall; }
    public void setStartTime(Date time) { this.startTime = time; }


    //座位检查

    // 获取已售座位集合
    public Set<String> getSoldSeats() { return soldSeats; }

    public void setSoldSeats(Set<String> soldSeats) {
        this.soldSeats = soldSeats;
    }
}